Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

245
Views
Prevent new WordPress users from logging in until manually "activated"?

I'm developing a plugin for WordPress which has 3 groups of users. I need to disable some users and prevent them from login. what I mean isn't preventing them to access the backend. I want to prevent them from is log in. For example, when they want to login they should see a message like this account isn't active yet. thank you guys.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

after some search and see similar problems I solved this problam like this : first add a user meta for user status so we can checking if user is active or not then we can disable or enable users.

add_filter( 'authenticate', 'chk_active_user',100,2);
function chk_active_user ($user,$username) 
   {
     $user_data = $user->data;
     $user_id = $user_data->ID;
     $user_sts = get_user_meta($user_id,"user_active_status",true);
     if ($user_sts==="no")
     {
        return new WP_Error( 'disabled_account','this account is disabled');

      }
      else
      {
       return $user;
      }
        return $user;
     }
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!